<?php namespace app\system\controller;

use app\admin\controller\Common;
use houdunwang\request\Request;
use houdunwang\route\Controller;
use system\model\Config as ConfigModel;

class Config extends Common {
	public function __construct()
	{
		$this->auth();
	}

	//动作
	public function setting ( ConfigModel $config )
	{
		if ( IS_POST ) {
			$config->setConfig( Request::post() );

			return $this->setRedirect('refresh')->success('操作成功');
		}
		//获取数据库的数据
		$model = ConfigModel::find(1);
		//注意这个判断，如果能找到数据，将其转为数组，分配到页面，
		//找不到数据，默认给空数组
		$field = $model ? json_decode($model['system'],true) : [];
		//此处书写代码...
		return view( '' ,compact('field'));
	}
}
